<!doctype html>



  


<html class="theme-next muse use-motion" lang="zh-Hans">
<head>
  <meta charset="UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>









<meta http-equiv="Cache-Control" content="no-transform" />
<meta http-equiv="Cache-Control" content="no-siteapp" />















  
  
  <link href="/lib/fancybox/source/jquery.fancybox.css?v=2.1.5" rel="stylesheet" type="text/css" />




  
  
  
  

  
    
    
  

  

  

  

  

  
    
    
    <link href="//fonts.googleapis.com/css?family=Lato:300,300italic,400,400italic,700,700italic&subset=latin,latin-ext" rel="stylesheet" type="text/css">
  






<link href="/lib/font-awesome/css/font-awesome.min.css?v=4.6.2" rel="stylesheet" type="text/css" />

<link href="/css/main.css?v=5.1.1" rel="stylesheet" type="text/css" />


  <meta name="keywords" content="MongoDB," />








  <link rel="shortcut icon" type="image/x-icon" href="/favicon.ico?v=5.1.1" />






<meta name="description" content="&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;本文教程只适合在 PHP7 的环境，如果是 PHP5 环境，可以参阅 MongoDB PHP PHP7 Mongdb 扩展安装&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;使用 pecl 命令来安装： 1$ /usr/local/php7/bin/pec">
<meta name="keywords" content="MongoDB">
<meta property="og:type" content="article">
<meta property="og:title" content="MongoDB PHP7">
<meta property="og:url" content="https://hcldirgit.github.io/2017/09/03/MongoDB/9. MongoDB PHP7/index.html">
<meta property="og:site_name" content="失落的乐章">
<meta property="og:description" content="&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;本文教程只适合在 PHP7 的环境，如果是 PHP5 环境，可以参阅 MongoDB PHP PHP7 Mongdb 扩展安装&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;使用 pecl 命令来安装： 1$ /usr/local/php7/bin/pec">
<meta property="og:locale" content="zh-Hans">
<meta property="og:image" content="https://github.com/hcldirgit/image/blob/master/MongoDB%20PHP7/01.jpeg?raw=true">
<meta property="og:updated_time" content="2017-09-01T08:55:56.081Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="MongoDB PHP7">
<meta name="twitter:description" content="&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;本文教程只适合在 PHP7 的环境，如果是 PHP5 环境，可以参阅 MongoDB PHP PHP7 Mongdb 扩展安装&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;使用 pecl 命令来安装： 1$ /usr/local/php7/bin/pec">
<meta name="twitter:image" content="https://github.com/hcldirgit/image/blob/master/MongoDB%20PHP7/01.jpeg?raw=true">



<script type="text/javascript" id="hexo.configurations">
  var NexT = window.NexT || {};
  var CONFIG = {
    root: '/',
    scheme: 'Muse',
    sidebar: {"position":"left","display":"post","offset":12,"offset_float":0,"b2t":false,"scrollpercent":false},
    fancybox: true,
    motion: true,
    duoshuo: {
      userId: '0',
      author: '博主'
    },
    algolia: {
      applicationID: '',
      apiKey: '',
      indexName: '',
      hits: {"per_page":10},
      labels: {"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}
    }
  };
</script>



  <link rel="canonical" href="https://hcldirgit.github.io/2017/09/03/MongoDB/9. MongoDB PHP7/"/>





  <title>MongoDB PHP7 | 失落的乐章</title>
</head>

<body itemscope itemtype="http://schema.org/WebPage" lang="zh-Hans">

  




<script>
  (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
            (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
          m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
  })(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
  ga('create', '85*****1', 'auto');
  ga('send', 'pageview');
</script>


  <script type="text/javascript">
    var _hmt = _hmt || [];
    (function() {
      var hm = document.createElement("script");
      hm.src = "https://hm.baidu.com/hm.js?87980c**************99ec5e26fb5";
      var s = document.getElementsByTagName("script")[0];
      s.parentNode.insertBefore(hm, s);
    })();
  </script>











  
  
    
  

  <div class="container sidebar-position-left page-post-detail ">
    <div class="headband"></div>

    <header id="header" class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-wrapper">
  <div class="site-meta ">
    

    <div class="custom-logo-site-title">
      <a href="/"  class="brand" rel="start">
        <span class="logo-line-before"><i></i></span>
        <span class="site-title">失落的乐章</span>
        <span class="logo-line-after"><i></i></span>
      </a>
    </div>
      
        <p class="site-subtitle">技术面前，永远都是学生。</p>
      
  </div>

  <div class="site-nav-toggle">
    <button>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
    </button>
  </div>
</div>

<nav class="site-nav">
  

  
    <ul id="menu" class="menu">
      
        
        <li class="menu-item menu-item-home">
          <a href="/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-home"></i> <br />
            
            首页
          </a>
        </li>
      
        
        <li class="menu-item menu-item-categories">
          <a href="/categories" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-th"></i> <br />
            
            分类
          </a>
        </li>
      
        
        <li class="menu-item menu-item-tags">
          <a href="/tags" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-tags"></i> <br />
            
            标签
          </a>
        </li>
      
        
        <li class="menu-item menu-item-message">
          <a href="/message" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-external-link"></i> <br />
            
            留言
          </a>
        </li>
      

      
    </ul>
  

  
</nav>



 </div>
    </header>

    <main id="main" class="main">
      <div class="main-inner">
        <div class="content-wrap">
          <div id="content" class="content">
            

  <div id="posts" class="posts-expand">
    

  

  
  
  

  <article class="post post-type-normal " itemscope itemtype="http://schema.org/Article">
    <link itemprop="mainEntityOfPage" href="https://hcldirgit.github.io/2017/09/03/MongoDB/9. MongoDB PHP7/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="失落的乐章">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/images/0.png">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="失落的乐章">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">MongoDB PHP7</h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2017-09-03T02:06:42+08:00">
                2017-09-03
              </time>
            

            

            
          </span>

          

          
            
          

          
          

          

          

          

        </div>
      </header>
    

    <div class="post-body" itemprop="articleBody">

      
      

      
        <p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;本文教程只适合在 PHP7 的环境，如果是 PHP5 环境，可以参阅 <a href="https://hcldirgit.github.io/2017/08/27/MongoDB/8.%20MongoDB%20PHP/">MongoDB PHP</a></p>
<h2 id="PHP7-Mongdb-扩展安装"><a href="#PHP7-Mongdb-扩展安装" class="headerlink" title="PHP7 Mongdb 扩展安装"></a>PHP7 Mongdb 扩展安装</h2><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;使用 pecl 命令来安装：</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">$ /usr/<span class="built_in">local</span>/php7/bin/pecl install mongodb</div></pre></td></tr></table></figure>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;执行成功后，会输出以下结果：</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div></pre></td><td class="code"><pre><div class="line">……</div><div class="line">Build process completed successfully</div><div class="line">Installing <span class="string">'/usr/local/php7/lib/php/extensions/no-debug-non-zts-20151012/mongodb.so'</span></div><div class="line">install ok: channel://pecl.php.net/mongodb-1.1.7</div><div class="line">configuration option <span class="string">"php_ini"</span> is not <span class="built_in">set</span> to php.ini location</div><div class="line">You should add <span class="string">"extension=mongodb.so"</span> to php.ini</div></pre></td></tr></table></figure>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;接下来打开 php.ini 文件，添加 <strong>extension=mongodb.so</strong> 配置。</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;可以直接执行以下命令来添加。</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">$ <span class="built_in">echo</span> <span class="string">"extension=mongodb.so"</span> &gt;&gt; `/usr/<span class="built_in">local</span>/php7/bin/php --ini | grep <span class="string">"Loaded Configuration"</span> | sed -e <span class="string">"s|.*:\s*||"</span>`</div></pre></td></tr></table></figure>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<strong>注意</strong>：<em>以上执行的命令中 php7 的安装目录为 /usr/local/php7/，如果你安装在其他目录，需要相应修改 pecl 与 php 命令的路径。</em></p>
<h2 id="Mongodb-使用"><a href="#Mongodb-使用" class="headerlink" title="Mongodb 使用"></a>Mongodb 使用</h2><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;PHP7 连接 MongoDB 语法如下：</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line"><span class="variable">$manager</span> = new MongoDB\Driver\Manager(<span class="string">"mongodb://localhost:27017"</span>);</div></pre></td></tr></table></figure>
<h3 id="插入数据"><a href="#插入数据" class="headerlink" title="插入数据"></a>插入数据</h3><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;将 name 为”菜鸟教程” 的数据插入到 test 数据库的 runoob 集合中。</p>
<figure class="highlight php"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div></pre></td><td class="code"><pre><div class="line"><span class="meta">&lt;?php</span></div><div class="line">$bulk = <span class="keyword">new</span> MongoDB\Driver\BulkWrite;</div><div class="line">$document = [<span class="string">'_id'</span> =&gt; <span class="keyword">new</span> MongoDB\BSON\ObjectID, <span class="string">'name'</span> =&gt; <span class="string">'菜鸟教程'</span>];</div><div class="line"> </div><div class="line">$_id= $bulk-&gt;insert($document);</div><div class="line"> </div><div class="line">var_dump($_id);</div><div class="line"> </div><div class="line">$manager = <span class="keyword">new</span> MongoDB\Driver\Manager(<span class="string">"mongodb://localhost:27017"</span>); </div><div class="line">$writeConcern = <span class="keyword">new</span> MongoDB\Driver\WriteConcern(MongoDB\Driver\WriteConcern::MAJORITY, <span class="number">1000</span>);</div><div class="line">$result = $manager-&gt;executeBulkWrite(<span class="string">'test.runoob'</span>, $bulk, $writeConcern);</div><div class="line"><span class="meta">?&gt;</span></div></pre></td></tr></table></figure>
<h3 id="读取数据"><a href="#读取数据" class="headerlink" title="读取数据"></a>读取数据</h3><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;这里将三个网址数据插入到 test 数据库的 sites 集合，并读取迭代出来：</p>
<figure class="highlight php"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div><div class="line">19</div><div class="line">20</div><div class="line">21</div><div class="line">22</div><div class="line">23</div><div class="line">24</div></pre></td><td class="code"><pre><div class="line"><span class="meta">&lt;?php</span></div><div class="line">$manager = <span class="keyword">new</span> MongoDB\Driver\Manager(<span class="string">"mongodb://localhost:27017"</span>); </div><div class="line"></div><div class="line"><span class="comment">// 插入数据</span></div><div class="line">$bulk = <span class="keyword">new</span> MongoDB\Driver\BulkWrite;</div><div class="line">$bulk-&gt;insert([<span class="string">'x'</span> =&gt; <span class="number">1</span>, <span class="string">'name'</span>=&gt;<span class="string">'菜鸟教程'</span>, <span class="string">'url'</span> =&gt; <span class="string">'http://www.runoob.com'</span>]);</div><div class="line">$bulk-&gt;insert([<span class="string">'x'</span> =&gt; <span class="number">2</span>, <span class="string">'name'</span>=&gt;<span class="string">'Google'</span>, <span class="string">'url'</span> =&gt; <span class="string">'http://www.google.com'</span>]);</div><div class="line">$bulk-&gt;insert([<span class="string">'x'</span> =&gt; <span class="number">3</span>, <span class="string">'name'</span>=&gt;<span class="string">'taobao'</span>, <span class="string">'url'</span> =&gt; <span class="string">'http://www.taobao.com'</span>]);</div><div class="line">$manager-&gt;executeBulkWrite(<span class="string">'test.sites'</span>, $bulk);</div><div class="line"></div><div class="line">$filter = [<span class="string">'x'</span> =&gt; [<span class="string">'$gt'</span> =&gt; <span class="number">1</span>]];</div><div class="line">$options = [</div><div class="line">    <span class="string">'projection'</span> =&gt; [<span class="string">'_id'</span> =&gt; <span class="number">0</span>],</div><div class="line">    <span class="string">'sort'</span> =&gt; [<span class="string">'x'</span> =&gt; <span class="number">-1</span>],</div><div class="line">];</div><div class="line"></div><div class="line"><span class="comment">// 查询数据</span></div><div class="line">$query = <span class="keyword">new</span> MongoDB\Driver\Query($filter, $options);</div><div class="line">$cursor = $manager-&gt;executeQuery(<span class="string">'test.sites'</span>, $query);</div><div class="line"></div><div class="line"><span class="keyword">foreach</span> ($cursor <span class="keyword">as</span> $document) &#123;</div><div class="line">    print_r($document);</div><div class="line">&#125;</div><div class="line"><span class="meta">?&gt;</span></div></pre></td></tr></table></figure>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;输出结果为：</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div></pre></td><td class="code"><pre><div class="line">stdClass Object</div><div class="line">(</div><div class="line">    [x] =&gt; 3</div><div class="line">    [name] =&gt; taobao</div><div class="line">    [url] =&gt; http://www.taobao.com</div><div class="line">)</div><div class="line">stdClass Object</div><div class="line">(</div><div class="line">    [x] =&gt; 2</div><div class="line">    [name] =&gt; Google</div><div class="line">    [url] =&gt; http://www.google.com</div><div class="line">)</div></pre></td></tr></table></figure>
<h3 id="更新数据"><a href="#更新数据" class="headerlink" title="更新数据"></a>更新数据</h3><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;接下来我们将更新 test 数据库 sites 集合中 x 为 2 的数据：</p>
<figure class="highlight php"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div></pre></td><td class="code"><pre><div class="line"><span class="meta">&lt;?php</span></div><div class="line">$bulk = <span class="keyword">new</span> MongoDB\Driver\BulkWrite;</div><div class="line">$bulk-&gt;update(</div><div class="line">    [<span class="string">'x'</span> =&gt; <span class="number">2</span>],</div><div class="line">    [<span class="string">'$set'</span> =&gt; [<span class="string">'name'</span> =&gt; <span class="string">'菜鸟工具'</span>, <span class="string">'url'</span> =&gt; <span class="string">'tool.runoob.com'</span>]],</div><div class="line">    [<span class="string">'multi'</span> =&gt; <span class="keyword">false</span>, <span class="string">'upsert'</span> =&gt; <span class="keyword">false</span>]</div><div class="line">);</div><div class="line"></div><div class="line">$manager = <span class="keyword">new</span> MongoDB\Driver\Manager(<span class="string">"mongodb://localhost:27017"</span>); </div><div class="line">$writeConcern = <span class="keyword">new</span> MongoDB\Driver\WriteConcern(MongoDB\Driver\WriteConcern::MAJORITY, <span class="number">1000</span>);</div><div class="line">$result = $manager-&gt;executeBulkWrite(<span class="string">'test.sites'</span>, $bulk, $writeConcern);</div><div class="line"><span class="meta">?&gt;</span></div></pre></td></tr></table></figure>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;接下来我们使用 “db.sites.find()” 命令查看数据的变化，x 为 2 的数据已经变成了菜鸟工具：</p>
<p><img src="https://github.com/hcldirgit/image/blob/master/MongoDB%20PHP7/01.jpeg?raw=true" alt=""></p>
<h3 id="删除数据"><a href="#删除数据" class="headerlink" title="删除数据"></a>删除数据</h3><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;以下实例删除了 x 为 1 和 x 为 2的数据，注意 limit 参数的区别：</p>
<figure class="highlight php"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div></pre></td><td class="code"><pre><div class="line"><span class="meta">&lt;?php</span></div><div class="line">$bulk = <span class="keyword">new</span> MongoDB\Driver\BulkWrite;</div><div class="line">$bulk-&gt;delete([<span class="string">'x'</span> =&gt; <span class="number">1</span>], [<span class="string">'limit'</span> =&gt; <span class="number">1</span>]); <span class="comment">// limit 为 1 时，删除第一条匹配数据</span></div><div class="line">$bulk-&gt;delete([<span class="string">'x'</span> =&gt; <span class="number">2</span>], [<span class="string">'limit'</span> =&gt; <span class="number">0</span>]); <span class="comment">// limit 为 0 时，删除所有匹配数据</span></div><div class="line"> </div><div class="line">$manager = <span class="keyword">new</span> MongoDB\Driver\Manager(<span class="string">"mongodb://localhost:27017"</span>); </div><div class="line">$writeConcern = <span class="keyword">new</span> MongoDB\Driver\WriteConcern(MongoDB\Driver\WriteConcern::MAJORITY, <span class="number">1000</span>);</div><div class="line">$result = $manager-&gt;executeBulkWrite(<span class="string">'test.sites'</span>, $bulk, $writeConcern);</div><div class="line"><span class="meta">?&gt;</span></div></pre></td></tr></table></figure>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;更多使用方法请参考：<a href="http://php.net/manual/en/book.mongodb.php。" target="_blank" rel="external">http://php.net/manual/en/book.mongodb.php。</a></p>

      
    </div>

    <div>
      
        

      
    </div>

    <div>
      
        

      
    </div>

    <div>
      
        

      
    </div>

    <footer class="post-footer">
      
        <div class="post-tags">
          
            <a href="/tags/MongoDB/" rel="tag"># MongoDB</a>
          
        </div>
      

      
      
      

      
        <div class="post-nav">
          <div class="post-nav-next post-nav-item">
            
              <a href="/2017/09/03/MongoDB/8. MongoDB PHP/" rel="next" title="MongoDB PHP">
                <i class="fa fa-chevron-left"></i> MongoDB PHP
              </a>
            
          </div>

          <span class="post-nav-divider"></span>

          <div class="post-nav-prev post-nav-item">
            
              <a href="/2017/09/03/MySQL/1. Mysql安装/" rel="prev" title="MySQL安装">
                MySQL安装 <i class="fa fa-chevron-right"></i>
              </a>
            
          </div>
        </div>
      

      
      
    </footer>
  </article>



    <div class="post-spread">
      
    </div>
  </div>


          </div>
          


          
  <div class="comments" id="comments">
    
  </div>


        </div>
        
          
  
  <div class="sidebar-toggle">
    <div class="sidebar-toggle-line-wrap">
      <span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
    </div>
  </div>

  <aside id="sidebar" class="sidebar">
    <div class="sidebar-inner">

      

      
        <ul class="sidebar-nav motion-element">
          <li class="sidebar-nav-toc sidebar-nav-active" data-target="post-toc-wrap" >
            文章目录
          </li>
          <li class="sidebar-nav-overview" data-target="site-overview">
            站点概览
          </li>
        </ul>
      

      <section class="site-overview sidebar-panel">
        <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
          <img class="site-author-image" itemprop="image"
               src="/images/0.png"
               alt="失落的乐章" />
          <p class="site-author-name" itemprop="name">失落的乐章</p>
           
              <p class="site-description motion-element" itemprop="description">失落的乐章的Blog</p>
          
        </div>
        <nav class="site-state motion-element">

          
            <div class="site-state-item site-state-posts">
              <a href="/">
                <span class="site-state-item-count">627</span>
                <span class="site-state-item-name">日志</span>
              </a>
            </div>
          

          

          
            
            
            <div class="site-state-item site-state-tags">
              <a href="/tags/index.html">
                <span class="site-state-item-count">38</span>
                <span class="site-state-item-name">标签</span>
              </a>
            </div>
          

        </nav>

        

        <div class="links-of-author motion-element">
          
            
              <span class="links-of-author-item">
                <a href="https://github.com/hcldirgit" target="_blank" title="GitHub">
                  
                    <i class="fa fa-fw fa-github"></i>
                  
                  GitHub
                </a>
              </span>
            
          
        </div>

        
        

        
        

        


      </section>

      
      <!--noindex-->
        <section class="post-toc-wrap motion-element sidebar-panel sidebar-panel-active">
          <div class="post-toc">

            
              
            

            
              <div class="post-toc-content"><ol class="nav"><li class="nav-item nav-level-2"><a class="nav-link" href="#PHP7-Mongdb-扩展安装"><span class="nav-number">1.</span> <span class="nav-text">PHP7 Mongdb 扩展安装</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#Mongodb-使用"><span class="nav-number">2.</span> <span class="nav-text">Mongodb 使用</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#插入数据"><span class="nav-number">2.1.</span> <span class="nav-text">插入数据</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#读取数据"><span class="nav-number">2.2.</span> <span class="nav-text">读取数据</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#更新数据"><span class="nav-number">2.3.</span> <span class="nav-text">更新数据</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#删除数据"><span class="nav-number">2.4.</span> <span class="nav-text">删除数据</span></a></li></ol></li></ol></div>
            

          </div>
        </section>
      <!--/noindex-->
      

      

    </div>
  </aside>


        
      </div>
    </main>

    <footer id="footer" class="footer">
      <div class="footer-inner">
        <div class="copyright" >
  
  &copy; 
  <span itemprop="copyrightYear">2017</span>
  <span class="with-love">
    <i class="fa fa-heart"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">失落的乐章</span>
</div>


<div class="powered-by">
  由 <a class="theme-link" href="https://hexo.io">Hexo</a> 强力驱动
</div>

<div class="theme-info">
  主题 -
  <a class="theme-link" href="https://github.com/iissnan/hexo-theme-next">
    NexT.Muse
  </a>
</div>


        

        
      </div>
    </footer>

    
      <div class="back-to-top">
        <i class="fa fa-arrow-up"></i>
        
      </div>
    

  </div>

  

<script type="text/javascript">
  if (Object.prototype.toString.call(window.Promise) !== '[object Function]') {
    window.Promise = null;
  }
</script>









  












  
  <script type="text/javascript" src="/lib/jquery/index.js?v=2.1.3"></script>

  
  <script type="text/javascript" src="/lib/fastclick/lib/fastclick.min.js?v=1.0.6"></script>

  
  <script type="text/javascript" src="/lib/jquery_lazyload/jquery.lazyload.js?v=1.9.7"></script>

  
  <script type="text/javascript" src="/lib/velocity/velocity.min.js?v=1.2.1"></script>

  
  <script type="text/javascript" src="/lib/velocity/velocity.ui.min.js?v=1.2.1"></script>

  
  <script type="text/javascript" src="/lib/fancybox/source/jquery.fancybox.pack.js?v=2.1.5"></script>


  


  <script type="text/javascript" src="/js/src/utils.js?v=5.1.1"></script>

  <script type="text/javascript" src="/js/src/motion.js?v=5.1.1"></script>



  
  

  
  <script type="text/javascript" src="/js/src/scrollspy.js?v=5.1.1"></script>
<script type="text/javascript" src="/js/src/post-details.js?v=5.1.1"></script>



  


  <script type="text/javascript" src="/js/src/bootstrap.js?v=5.1.1"></script>



  


  




	





  





  





  






  





  

  

  

  

  

  

</body>
</html>
